package com.ssy.util;

import com.alibaba.fastjson.JSONObject;
import com.ssy.common.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * RespUtil
 * <p>
 * 向浏览器响应json数据
 *
 * @author ssy
 * @date 2020/11/11
 **/
public class RespUtil {

    public RespUtil() {
    }

    public static void write(HttpServletResponse resp, Result rs) {
        resp.setContentType("text/json;charset=UTF-8");
        try {
            resp.getWriter().print(JSONObject.toJSONString(rs));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
